<%@ taglib uri="/WEB-INF/displaytag-12.tld" prefix="display" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url();
	background-color: #CCCCCC;
}
-->
</style>
<link href="../css/droik.css" rel="stylesheet" type="text/css">
<link href="../css/sifr.print.css" rel="stylesheet" type="text/css">
<link href="../css/browse.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>

<style type="text/css">
<!--
.style3 {color: #2399b3}
.style5 {color: #00105E}
-->
</style>
<script>
function changeStatus()
{
	debugger;
	if(document.getElementById('listPict').checked) {
		document.getElementById('listPict').value = "on";
	} else {
		document.getElementById('listPict').value = "off";
	}

}
function goBack() {
	var url;
	<%
		String cnt = (String) session.getAttribute("back");
		if("index".equals(cnt)) {
	%>
			url = "../portal/index.do";
	<%
		} else {
	%>
			url = "../jsp/SearchClassifieds.jsp?PostingType=" + "<%=request.getParameter("PostingType")%>";
			<%
				if(null!=request.getParameter("CatType")) {
			%>
				url = url + "&CatType=" + "<%=request.getParameter("CatType")%>";
			<%
				}
			%>
			<%
				if(null!=request.getParameter("pricemin")) {
			%>
				url = url + "&pricemin=" + "<%=request.getParameter("pricemin")%>";
			<%
				}
			%>
			<%
				if(null!=request.getParameter("pricemax")) {
			%>
				url = url + "&pricemax=" + "<%=request.getParameter("pricemax")%>";
			<%
				}
			%>
			<%
				if(null!=request.getParameter("excludeSearchContent")) {
			%>
				url = url + "&excludeSearchContent=" + "<%=request.getParameter("excludeSearchContent")%>";
			<%
				}
			%>
			<%
				if(null!=request.getParameter("adContent")) {
			%>
				url = url + "&adContent=" + "<%=request.getParameter("adContent")%>";
			<%
				}
			%>
			<%
				if(null!=request.getParameter("City")) {				
			%>
				url = url + "&City=" + "<%=request.getParameter("City")%>";				
			<%
				}
			%>
			<%
				if(null!=request.getParameter("Place")) {
			%>
				url = url + "&Place=" + "<%=request.getParameter("Place")%>";
			<%
				}
			%>
			<%
				if(null!=request.getParameter("listPict")) {
			%>
				url = url + "&listPict=" + "<%=request.getParameter("listPict")%>";
			<%
				}
			%>
	<%
		}
		out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
	%>

	window.location.href = url;
}
function checkNum(fieldName, fieldVal, fieldLen){
    //Check whether the value of the field is a number
    if (isNaN(fieldVal)==true ||
        (fieldLen!=fieldVal.length &&
            fieldLen!=0)){
        //if it is not a number display a message
        if (fieldLen==0)
         {
            //Message for variable length numbers
            document.form1.elements[fieldName].focus();
            alert("This must be a number.");

            return false;
        }
        else
         {
            //Message for fixed length fields
            document.form1.elements[fieldName].focus();
            alert("This must be a " + fieldLen + " digit number.");

            return false;
        }
    }
}
</script>
</head>

<body>
	<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td>
			<%
				java.util.Hashtable allArea = (java.util.Hashtable)application.getAttribute("APALLCATEGORY");
				java.util.Hashtable allAreaId = (java.util.Hashtable)application.getAttribute("APCATIDS");
				String catType =request.getParameter("CatType");    	
				session.setAttribute("CatType",catType);
				int catId;
				String mainCatId;
				String subCatName;
				String mainCatName="";
				int postingID=0;
				
				if (catType!=null)
				{
					catId =  Integer.parseInt(catType);
				} 
				else 
				{
					catId=0;
				}				
				if (catId==0)
				{
					subCatName="";
					mainCatId = request.getParameter("PostingType");
					
					if (mainCatId!=null && mainCatId.length()>0)
					{
						postingID = Integer.parseInt(mainCatId);
					}
						session.setAttribute("PostingType",mainCatId);
					if (mainCatId.equals("99"))
					{
						mainCatName="All Categories";
					}
					else
					{
						mainCatName = (String)allArea.get(mainCatId);
					}
				}
				else
				{
					mainCatId = (String)allAreaId.get(catId+"");
					subCatName = (String)allArea.get(catId+"");
					mainCatName = (String)allArea.get(mainCatId);
				}
			%>
				<form name="form1" method="post" action="../portal/SearchAdv.do?action=SearchAd&PostingType=<%=mainCatId%>&CatType=<%=catId%>">
					<table width="100%"  border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td>
								<jsp:include page="/jsp/top.jsp"/>
							</td>
						</tr>
						<tr>
							<td>
								<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
									<tr>
										<td width="14%"> <a href="#"><img src="../Pune360/images/zz1a_03.jpg" alt="" width="141" height="56" border="0"></a></td>
										<td width="14%"> <a href="#"><img src="../Pune360/images/zz1a_04.jpg" alt="" width="141" height="56" border="0"></a></td>
										<td width="14%"> <a href="http://www.droik.com/aboutus.php"><img src="../Pune360/images/zz1a_05.jpg" alt="" width="141" height="56" border="0"></a></td>
										<td width="13%"> <a href="http://www.droik.com/contact.php"><img src="../Pune360/images/zz1a_06.jpg" alt="" width="137" height="56" border="0"></a></td>
										<td width="45%" colspan="2" style="background-image:url(../Pune360/images/zz1a_07.jpg)">
											<table style="margin-left:30px">
												<tr>
													<td><a href="http://www.droik.com/" class="cityfonts">All Cities</a></td>
													<td><a href="http://www.droik.com/Ahmedabad" class="cityfonts">Ahmedabad</a></td>
													<td><a href="http://www.droik.com/Bangalore" class="cityfonts">Bangalore</a></td>
													<td><a href="http://www.droik.com/Chennai" class="cityfonts">Chennai</a></td>
													<td></td>
												</tr>
												<tr>
													<td><a href="http://www.droik.com/Delhi" class="cityfonts">Delhi</a></td>
													<td><a href="http://www.droik.com/Hyderabad" class="cityfonts">Hyderabad</a></td>
													<td><a href="http://www.droik.com/Kolkata" class="cityfonts">Kolkata</a></td>
													<td><a href="http://www.droik.com/Mumbai" class="cityfonts">Mumbai</a></td>
													<td><a href="http://www.droik.com/Pune" class="cityfonts">Pune</a></td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</td>
						</tr>
<tr>
	<td height="232" valign="top" bgcolor="#FFFFFF">
		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="77%" valign="top">
					<table width="97%"  border="0" align="center" cellpadding="0" cellspacing="0">
						<tr>
							<td class="text style3"><img src="../Pune360/images/spacer.gif" width="1" height="10"></td>
						</tr>
						<tr>
							<td height="25" class="text style3">
								<table width="100%"  border="0" cellspacing="0" cellpadding="0">                 
								<%
									String pricemin = request.getParameter("pricemin");
									if (pricemin==null)
										pricemin="";
										session.setAttribute("pricemin",pricemin);
										String pricemax = request.getParameter("pricemax");
									if (pricemax==null)
										pricemax="";
										session.setAttribute("pricemax",pricemax);
										String adContent = request.getParameter("adContent");
										String excludeSearchContent= request.getParameter("excludeSearchContent");
									if (adContent==null)
										adContent="";
										session.setAttribute("adContent",adContent);
									if (excludeSearchContent==null)
										excludeSearchContent="";
										session.setAttribute("excludeSearchContent",excludeSearchContent);
										session.setAttribute("City", request.getParameter("City"));			
										session.setAttribute("listPict",request.getParameter("listPict"));
									if (mainCatId.equals("1") || mainCatId.equals("2")) 
									{	
								%>                  
									<tr class="dblu">
										<td width="21%" class="dblu">Price Min</td>
										<td width="29%"><input type="text" name="pricemin" class="form" value="<%=pricemin%>"  onchange="return checkNum('pricemin', pricemin.value, 0)"></td>
										<td width="14%">Price Max</td>
										<td width="36%"><input type="text" name="pricemax" class="form" value="<%=pricemax%>" onBlur="return checkNum('pricemax', pricemax.value, 0)"></td>
									</tr>
								<%	}%>
									<tr class="dblu">
										<td width="21%" class="dblu">Search Words</td>
										<td width="29%"><input type="text" class="form" name="adContent" value="<%=adContent%>"></td>
										<td width="14%">Exclude Words </td>
										<td width="36%"><input name="excludeSearchContent" class="form" type="text" id="excludeSearchContent" value="<%=excludeSearchContent%>"></td>
									</tr>
										<%
										java.sql.Connection conn = null;
										java.sql.Statement  stat = null;
										java.sql.Statement  stat1 = null;
										int city_id = 0;		
										Class.forName("com.mysql.jdbc.Driver");	
										//conn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/ba3602_droikclassifieds","ba3602_portal", "p0rtal");
										conn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/ba3602_classifiedsdb","root","test" );
										stat = conn.createStatement();	
										stat1 = conn.createStatement();		
										String city = request.getParameter("City");		
										java.sql.ResultSet rs = stat.executeQuery("select city_id, cityname from lookup_city;");
										int cityid;
										String cityname;	
										%>
									<tr class="dblu">
										<td>City</td>
										<td>																
											<select name="City">																																																			
													<%				  			 				       	     
													while (rs.next()) 
													{													       
														cityid = rs.getInt(1);
														cityname = rs.getString(2);											
														%>								               
														<option value="<%=cityid%>"
														<%if(city !=null)
														  {
														  	if(Integer.parseInt(city) == cityid)														  	
														  	out.print("selected"); 														  	
														  }%>														
														><%=cityname%></option>				   			
												<%	}%>
											</select> 	
										</td>                    
										<td>
											with Pic
											<%
											if("on".equals(request.getParameter("listPict"))) 
											{
											%>
												<input type="checkbox" checked name="listPict" onClick="javascript:changeStatus()">
											<%
											} 
											else 
											{
											%>
												<input type="checkbox" name="listPict" onClick="javascript:changeStatus()">
											<%
											}
											%>
										</td>
										<td>
											<input name="Search" type="submit" value="Search">
										</td>                    
									</tr>
									<tr class="dblu">
										<td>&nbsp;</td>
										<td>&nbsp;</td>
										<td>&nbsp;</td>
										<td>&nbsp;</td>
									</tr>
								</table> 
							</td>
						</tr>
						<tr>
							<td class="text"><div align="center"><img src="../Pune360/images/line.jpg" width="725" height="3" vspace="5"></div></td>
						</tr>                            
						<tr>
							<td class="text"><div align="justify">
								<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#ececec">                  
									<tr>
										<td>
											<TABLE class=simple cellSpacing=1 cellPadding=2 width="100%" border=0>                        
												<TBODY>
													<%if (mainCatId.equals("1") || mainCatId.equals("2")) 
													{%>
													<%if (catType==null || catType.equals("0"))
													  {%>
														<tr bgcolor="#FFFFFF" class=odd>                           	
															<td colspan="6" valign="top"  height="44"><br>
																<display:table width="100%" cellpadding="4" cellspacing="1" border="1" class="simple" name="sessionScope.SEARCHRESULT" pagesize="50">
																	<display:column property="datePosted" title="Posted On" sortable="true" headerClass="title_link" group="1" />
																	<display:column property="adTitle" title="Featured Postings" href="../portal/postadv.do?action=DisplayAd" paramId="advId" paramProperty="advId" sortable="true" headerClass="title_link"/>
																	<display:column property="price" title="Price" sortable="true" headerClass="title_link"/>
																	<display:column property="subCategoryName" title="Sub-Category" sortable="true" headerClass="title_link" />
																	<display:column property="city" title="Place" sortable="true" headerClass="title_link" />
																</display:table>
															</td>
														</tr>
													<%}
													  else
													  {%>
														<tr bgcolor="#FFFFFF">
															<td colspan="6" valign="top"  height="44"><br>
																<display:table width="100%" cellpadding="4" cellspacing="1" border="1" class="simple" name="sessionScope.SEARCHRESULT" pagesize="50">
																	<display:column property="datePosted" title="Posted On" sortable="true" headerClass="title_link" group="1" />
																	<display:column property="adTitle" title="Featured Postings" href="../portal/postadv.do?action=DisplayAd" paramId="advId" paramProperty="advId" sortable="true" headerClass="title_link"/>
																	<display:column property="price" title="Price" sortable="true" headerClass="title_link"/>														
																	<display:column property="city" title="Place" sortable="true" headerClass="title_link" />
																</display:table>
															</td>
														</tr>
													<%}
													} 
													else 
													{%>
													<%if (catType==null)
													  {%>
														<tr bgcolor="#FFFFFF">
															<td colspan="6" valign="top"  height="25"> 
																<display:table width="100%" cellpadding="4" cellspacing="1" border="1" class="simple" name="sessionScope.SEARCHRESULT" pagesize="50" >
																	<display:column property="datePosted" title="Posted On" sortable="true" headerClass="title_link" group="1"/>
																	<display:column property="adTitle" title="Featured Postings" href="../portal/postadv.do?action=DisplayAd" paramId="advId" paramProperty="advId" sortable="true" headerClass="title_link"/>
																	<display:column property="subCategoryName" title="Sub-Category" sortable="true" headerClass="title_link" />
																	<display:column property="city" title="Place" sortable="true" headerClass="title_link" />
																</display:table>
															</td>
														</tr>
														<%}
														  else
														  {%>
														<tr bgcolor="#FFFFFF">
															<td colspan="6" valign="top"  height="25"> 
																<display:table width="100%" cellpadding="4" cellspacing="1" border="1" class="simple" name="sessionScope.SEARCHRESULT" pagesize="50" >
																	<display:column property="datePosted" title="Posted On" sortable="true" headerClass="title_link" group="1"/>
																	<display:column property="adTitle" title="Featured Postings" href="../portal/postadv.do?action=DisplayAd" paramId="advId" paramProperty="advId" sortable="true" headerClass="title_link"/>
																	<display:column property="city" title="Place" sortable="true" headerClass="title_link" />
																</display:table>
															</td>
														</tr>
														<%}
													     }%>
													</TR>                                                                           
												</TBODY>
											</TABLE>
										</td>
									</tr>
								</table>
									<div align="right"><br>				
										<img src="../Pune360/images/oranbutback.gif" onClick="javascript:goBack()"/>	
										<br>																									
									</div>
									</div>                  				
							</td>
						</tr>
						<tr>
							<td class="text">&nbsp;</td>
						</tr>
						<tr>
							<td class="text">&nbsp;</td>
						</tr>
					</table>
				</td>
				<td width="23%" valign="top"><img src="../Pune360/images/ad.jpg" width="250" height="673"></td>
			</tr>
		</table>
	</td>
</tr>
<tr>
<td><img src="../Pune360/images/zz1a_12.jpg" alt="" width="1000" height="43" border="0" usemap="#MapMapMapMap">
<map name="MapMapMapMap">
<area shape="rect" coords="620,5,680,27" href="contact.htm">
<area shape="rect" coords="528,6,577,26" href="about.htm">
<area shape="rect" coords="438,4,493,25" href="blog.htm">
<area shape="rect" coords="321,3,404,25" href="classifieds.htm">
</map></td>
</tr>
</table></td>
</tr>
</table>
<map name="MapMapMap">
  <area shape="rect" coords="596,5,656,27" href="contact.htm">
  <area shape="rect" coords="511,6,560,26" href="about.htm">
  <area shape="rect" coords="423,4,478,25" href="blog.htm">
  <area shape="rect" coords="312,3,395,25" href="classifieds.htm">
</map>
<map name="MapMap">
  <area shape="rect" coords="596,5,656,27" href="contact.htm">
  <area shape="rect" coords="511,6,560,26" href="about.htm">
  <area shape="rect" coords="423,4,478,25" href="blog.htm">
  <area shape="rect" coords="312,3,395,25" href="classifieds.htm">
</map>
</body>
</html>
